package plus.stmt;

import plus.Gripe;
import plus.exp.Exp;

public class P_Assign extends Statement {
	public String toString() { return "assignment"; }
	final Exp lhs, rhs;
	final int lineNr;

	public P_Assign(Exp lhs, int lineNr, Exp rhs) {
		this.lhs = lhs;
		this.rhs = rhs;
		this.lineNr = lineNr;
	}

	@Override
	public void threadScope() {
		Gripe.lineNr = lineNr;
		Gripe.context = this;
		rhs.threadScope();
		Gripe.lineNr = lineNr;
		Gripe.context = this;
		lhs.threadAssign();
		lhs.unify_with(rhs);
//		System.err.println(lhs.type + " := " + rhs.type);
//		System.err.println(VScope.current.find_variable("a").definition.type);
	}

	@Override
	public void compile() { lhs.compileAssign(rhs); }
}
